<?php
declare (strict_types = 1);

namespace app\api\controller;
use app\model\CategoryModel;
use app\model\CourseMenusModel;
use app\model\CourseModel;
use app\model\CourseOperationsModel;
use app\model\CourseUserRecordsModel;
use app\model\MenusModel;
use think\App;

class CourseOperations extends Base {

    private $courseOperationsModel;

    private $req;

    public function __construct(App $app)
    {
        parent::__construct($app);

        $this->req = request()->param();

        $this->page = isset($this->req['page']) ? $this->req['page']  : 1;

        $this->courseOperationsModel = new CourseOperationsModel();
    }



    public function getInfo()
    {
        $info = $this->courseOperationsModel->getInfo();

        $courseUserRecordsModel = new CourseUserRecordsModel();
        $courseModel = new CourseModel();
        $where=[];
        $where[] = ['is_delete','=',0];
        $where[] = ['course_id','=',$info["course_id"]];
        $info["course"] = $courseModel->getInfo($info["course_id"]);
        $info["study_num"] = $courseUserRecordsModel->getTotal($where);
        $info["user_records_list"] = $courseUserRecordsModel->getList($where,1,3);

        return $this->succ($info);
    }


}
